/* Reset and base styles for iframe compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    /* Responsive height - 450px for iframe, 90vh for full browser */
    height: 450px;
    width: 100%;
    overflow: hidden;
    user-select: none;
}

/* Check if running in full browser tab */
@media (min-height: 500px) {
    body {
        height: 90vh;
    }
}

/* Main container with cognitive load optimization */
.container {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-areas: 
        "staff staff"
        "notes recorder"
        "controls controls";
    grid-template-rows: 1fr 2fr 60px;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Musical staff styling - visual hierarchy principle */
.staff-container {
    grid-area: staff;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 15px;
}

.staff {
    position: relative;
    width: 200px;
    height: 80px;
}

.staff-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: #333;
    left: 0;
}

.staff-line:nth-child(1) { top: 0; }
.staff-line:nth-child(2) { top: 20px; }
.staff-line:nth-child(3) { top: 40px; }
.staff-line:nth-child(4) { top: 60px; }
.staff-line:nth-child(5) { top: 80px; }

/* Note display with animation for engagement */
.note-display {
    position: absolute;
    left: 20px;
    font-size: 48px;
    font-weight: bold;
    color: #1976d2;
    transition: all 0.3s ease;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* Note positioning on staff */
.note-display.C { top: 85px; }
.note-display.D { top: 75px; }
.note-display.E { top: 65px; }
.note-display.F { top: 55px; }
.note-display.G { top: 45px; }
.note-display.A { top: 35px; }
.note-display.B { top: 25px; }
.note-display.C-high { top: 15px; }

/* Note buttons - optimized for touch and cognitive load */
.note-buttons {
    grid-area: notes;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
}

.note-btn {
    background: linear-gradient(145deg, #42a5f5, #1976d2);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    /* Minimum touch target size for accessibility */
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    background: linear-gradient(145deg, #64b5f6, #2196f3);
}

.note-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.note-btn.active {
    background: linear-gradient(145deg, #ff7043, #d84315);
    animation: pulse 0.6s ease-in-out;
}

.high-c {
    background: linear-gradient(145deg, #ab47bc, #7b1fa2);
}

/* Recorder visual representation */
.recorder-container {
    grid-area: recorder;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.recorder {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.recorder-body {
    width: 40px;
    height: 280px;
    background: linear-gradient(to bottom, #8d6e63, #5d4037);
    border-radius: 20px;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.mouthpiece {
    width: 45px;
    height: 25px;
    background: linear-gradient(to bottom, #6d4c41, #4e342e);
    border-radius: 22px 22px 8px 8px;
    position: absolute;
    top: -12px;
    left: -2.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.recorder-foot {
    width: 35px;
    height: 30px;
    background: linear-gradient(to bottom, #6d4c41, #4e342e);
    border-radius: 0 0 17px 17px;
    position: absolute;
    bottom: -15px;
    left: 2.5px;
}

/* Hole styling with clear visual feedback */
.hole-container {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hole {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.back-thumb {
    position: absolute;
    left: -60px;
    top: 20px;
}

.hole-circle {
    width: 16px;
    height: 16px;
    border: 2px solid #333;
    border-radius: 50%;
    background: #fff;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hole-circle.filled {
    background: #333;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.hole-label {
    font-size: 10px;
    color: #333;
    margin-top: 4px;
    font-weight: bold;
}

/* Control buttons */
.controls {
    grid-area: controls;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.control-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.reset-btn {
    background: linear-gradient(145deg, #ff7043, #d84315);
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.help-btn {
    background: linear-gradient(145deg, #66bb6a, #388e3c);
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Modal styling for help */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.fingering-guide ul {
    margin-left: 20px;
    line-height: 1.6;
}

/* Animations for engagement */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        grid-template-areas: 
            "staff"
            "notes"
            "recorder"
            "controls";
        grid-template-rows: 1fr 1fr 1.5fr 60px;
        grid-template-columns: 1fr;
    }
    
    .note-buttons {
        grid-template-columns: repeat(8, 1fr);
        grid-template-rows: 1fr;
    }
    
    .recorder-body {
        height: 200px;
    }
    
    .hole-container {
        gap: 10px;
    }
}